<script type="text/javascript">
<!--
function checkAll(object,name){
	if(object.attr("checked") == true){
		$("input[name="+name+"]").each(function(){
			$(this).attr("checked",true);
		});
	}else{
		$("input[name="+name+"]").each(function(){
			$(this).attr("checked",false);
		});
	}
	
}

function updateItem(id){
	
	var url = '<?php echo $this->createUrl('iteminfo');?>';

	url = url.replace(/<?php echo Yii::app()->urlManager->urlSuffix;?>/,'/id/'+id+'<?php echo Yii::app()->urlManager->urlSuffix;?>');

//	alert(url);
//	$.get(url,function(msg){
//		alert(msg);
//	});
	
	$("#reply-"+id).load(url);
}

function getCheckedIds(name){
	var ids = new Array();
	$("input[name="+name+"]").each(function(){
		if($(this).attr("checked") == true){
			ids.push($(this).val());
		}
	});
	

	return ids.join(',');
}


function actionCommentsBatch(){
	var ids = getCheckedIds('comment-item');

	$.post('<?php echo $this->createUrl('comment/batchcomments'); ?>',{'id':ids,'ac':$("#comment-action").val()},function(data){
		if(data == 0){
		    $.msgbox({
		        height:100,
		        width:250,
		        content:{type:'alert', content: '修改成功！'},
		        animation:4
		    });
		}else{
		    $.msgbox({
		        height:100,
		        width:250,
		        content:{type:'alert', content: '有'+data+'个未成功进行！'},
		        animation:4
		    });		
		}
	});
}

function actionCommentLock(object){

	var url = object.attr("id");
	var id = object.attr("name");
	
    $.msgbox({
        height:100,
        width:250,
        content:{type:'alert', content: '确定锁定此评论？'},
        animation:4,
        onClose:function(v){
			$.post(url,{'Comment[com_status]':<?php echo Comment::COMMENT_LOCK;?>},function(data){
				if(data == 'ok'){
					load();
				}		
							
			});			
        }
   });

}


function actionResourceIsComment(object){

	var id = object.attr("id");
	var ac = object.attr("name");
	
	$.post('<?php echo $this->createUrl('comment/batchresource'); ?>',{'id':id,'ac':ac},function(data){
		if(data == 0){
		    $.msgbox({
		        height:100,
		        width:250,
		        content:{type:'alert', content: '修改成功！'},
		        animation:4,
		        onClose:function(){

		        }
		    });
		}	
	});

	updateItem(id);
}

function resourceHover(object){
	var id = object.attr("id");

	$.get('<?php echo $this->createUrl('comment/view');?>',{'id':id},function(msg){
		$("#comment-detail").slideDown().html(msg);
//		$("#comment-detail").html("dfjsl"+id);
	});

	$(".view").removeClass("hoverBg");

	object.addClass("hoverBg");
	
}
//-->
</script>
<div class="column1" style="width:100%;">
	<div class="box">
		<?php $this->beginWidget('zii.widgets.CPortlet', array('title'=>'News Statistics',	));?>
		<div class="box-content">
			<div style="margin-bottom: 10px;">
				<input type="checkbox" name="checkAll" onclick="checkAll($(this),'resource-item');" value="<?php echo $data->com_id;?>" />
				<?php echo Yii::t('common','Check All');?>
				&nbsp;&nbsp;&nbsp;&nbsp;
				<?php echo Yii::t('comment' ,'Comment State');?>：
				<?php echo CHtml::dropDownList($model,'',Comment::model()->generateCommentStateDropdownList(),array(
						'id'=>'comment-action'
				));?>
				&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="button" onclick="actionCommentsBatch();" value="<?php echo Yii::t('admin','Submit');?>" />
					
			</div>	
		
			<?php $this->widget('zii.widgets.CListView', array(
				'dataProvider'=>$dataProvider,
				'itemView'=>'_list',
			)); ?>	
			<hr class="space" />		
		</div>
		<?php $this->endWidget();?>		
	</div>
</div>
